package com.fengyun.scala

/**
 * @author Hanpeng
 * @date 2021/1/30 14:57
 * @description: Option 要么是scala.Some 的实例要么是None 的实例。
 *               最经常使用的方式是 ealed abstract classOption[+A] extends Product with Serializable
 */
object TestOption未完待续 {
  def main(args: Array[String]): Unit = {
    println("Step 1: How to use Option and Some - a basic example")
    //val glazedDonutTaste: Option[String] = Some("Very Tasty")
    val glazedDonutTaste: Option[String] = Some(null)
    println(s"Glazed Donut taste = ${glazedDonutTaste.get}")
    //
    println("=============")
    println("\nStep 2: How to use Option and None - a basic example")
    val glazedDonutName: Option[String] = None
    println(s"Glazed Donut name = ${glazedDonutName.getOrElse("Glazed Donut")}")
    // get 返回Option的value
    //abstract def isEmpty: Boolean  如果Option 为None 返回true
    //abstract def productArity: Int //product的size
    //productElement(n: Int): Any 从0 开始第n个元素
    //


  }
}





















